package com.chen.gulimall.search.controller;

import com.chen.gulimall.search.service.MallSearchService;
import com.chen.gulimall.search.vo.SearchParam;
import com.chen.gulimall.search.vo.SearchResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

@Controller
public class SearchController {

    @Autowired
    MallSearchService mallSearchService;

    @RequestMapping("/list.html")
    public String getListHtml(SearchParam searchParam, Model model, HttpServletRequest request){

        searchParam.set_queryString(request.getQueryString());
        SearchResult searchResult = mallSearchService.queryEsCategorys(searchParam);

        model.addAttribute("result",searchResult);
        return "list";
    }
}
